#include <bits/stdc++.h>

using namespace std;
#define int long long
const int inf = 0x3f3f3f3f3f3f3f3f;

void solve()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	int curmin = a[0], curmax = a[0];
	cout << curmin + curmax << ' ';
	map<int, int> mp;
	mp[a[0]]++;
	for (int k = 1; k < n; k++)
	{
		curmin = min(curmin, a[k]);
		curmax = max(curmax, a[k]);
		mp[a[k]]++;
		if (k == 1)
		{
			if (a[0] != a[1]) cout << 2 * max(a[0], a[1]) << ' ';
			else cout << curmin + curmax << ' ';
		}
		else
		{
			if (mp.size() == 2)
			{
				auto it1 = mp.begin();
				auto it2 = ++it1;
				it1--;
				if (it1->second == 1) cout << 2 * it2->first << ' ';
				else cout << curmin + curmax << ' ';
			}
			else cout << curmin + curmax << ' ';
		}
	}
	cout << '\n';
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int _ = 1;
	cin >> _;
	while (_--)
	{
		solve();
	}
	return 0;
}